package com.sann.demo.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * 读取Excel表格的监听器
 */
@Slf4j
public class ExcelListener extends AnalysisEventListener<DemoEntity> {

    /**
     * 读取Excel表头内容
     * @param headMap
     * @param context
     */
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        log.info("headMap:{}",headMap);
//        log.info("context:{}",context);
    }

    /**
     * 读取Excel除表头的正文内容
     * @param entity
     * @param analysisContext
     */
    @Override
    public void invoke(DemoEntity entity, AnalysisContext analysisContext) {
        log.info("entity:{}",entity);
//        log.info("analysisContext:{}",analysisContext);
    }

    /**
     * 读取完Excel后处理的业务逻辑
     * @param analysisContext
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
//        log.info("analysisContext：{}", analysisContext);
    }
}
